package file;

import java.io.File;
import java.util.HashMap;

public class Demo4 {
    public static void main(String[] args) {
        File f = new File("Day12");
        HashMap<String,Integer>map = new HashMap<>();
        tjFile(map,f);
    }

    private static void tjFile(HashMap<String, Integer> map, File f) {
        //判断是否为null,是否为文件
        if(f == null || f.isFile()){
            return;
        }
        //1.进入
        File[] files = f.listFiles();
        for (File file : files) {
            if(file.isFile()){
                String name = f.getName();
                String[] s = name.split("\\.");
                String s1 = s[s.length - 1];
                map.put(s1,map.containsKey(s1)? map.get(s1)+1:1);
            }else{
                tjFile(map, f);
            }
        }
    }
}
